package com.stk.triplecity;

import java.util.Locale;

import com.stk.triplecity.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Scores extends Activity{
	Button btn;
	EditText et;
	String name;
	TextView tv3;
	TextView tv1;
	int score;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.scores);
        
        Bundle extras =  getIntent().getExtras();
        score = extras.getInt("score");
        TextView scoresText = (TextView)findViewById(R.id.textView2);
        scoresText.setText(score + "");

        tv3 = (TextView)findViewById(R.id.textView3);
        tv1 = (TextView)findViewById(R.id.textView1);
        


        btn = (Button)findViewById(R.id.button1);
        btn.setOnClickListener(new OnClickListener() {
        	@Override
        	public void onClick(View v) {
        		et = (EditText)findViewById(R.id.editText1);
                name =  et.getText().toString();
                if(name.length() > 0){
        		SQLManager sql = new SQLManager(v.getContext());
        		sql.insert(name, score +"");
        		finish();
                }
        	}
        });
        
        if (Locale.getDefault().getLanguage().equals("es")){
	        //ES
        	tv3.setText("Inserte nombre:");
        	tv1.setBackgroundResource(R.drawable.scorees);
	    } else { 
	        //EN
	    	tv3.setText("Insert name:");	 
	    	tv1.setBackgroundResource(R.drawable.scoreen);
	    }
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if(keyCode == KeyEvent.KEYCODE_BACK){
			this.finish();
		}
		return true;
	}
}
